// 判断数据类型
const isObject = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Object]'
  }
  const isArray = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Array]'
  }
  const isString = function (obj) {
    return Object.prototype.toString.call(obj) === '[object String]'
  }
  const isNull = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Null]'
  }
  const isNumber = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Number]'
  }
  const isUndefined = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Undefined]'
  }
  const isBoolean = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Boolean]'
  }
  const isFunction = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Function]'
  }

export const clearObjVal = function (obj) {
    const newObj = obj
    if (isObject(newObj)) {
      Object.keys(newObj).forEach((item, index) => {
        newObj[item] = clearObjVal(newObj[item])
      })
    } else if (isArray(newObj)) {
      newObj.forEach((item, index) => {
        newObj[index] = clearObjVal(item)
      })
    } else if (isString(newObj)) {
      return newObj.trim()
    } else {
      return newObj
    }
    return newObj
  }